<?php
/*
 * ApplicationHelper(应用程序助手) 管理应用程序的配置信息
 * 读取配置文件中的数据并使客户端代码可以访问这些数据。
 * 
*/
class WooControllerApplicationHelper{
	private static $instance;
	private $config = "/tmp/woo_options.xml";

	private function __construct(){
		$this->config = 'abc';

	}

	static function instance(){
		if(! self::$instance){
			self::$instance = new self();
		}
		return self::$instance;
	}


	function init(){
		//$dsn = WooBaseApplicationRegistry::getDSN();
		/*$dsn = '';
		if(! is_null($dsn)){
			return ;
		}*/
		$this->getOptions();
	}


	private function getOptions(){
		//$this->ensure(file_exists($this->config),"Could not find options file");
		$options = @simplexml_load_file($this->config);
		//$this->ensure($dsn,"No DSN found");
		$dsn = 'test';
		$dsn_val = 'abc';
		foreach($options->control->view as $default_view){
			$stat_str = trim($default_view['status']);
			$status = WooCommandCommand::statuses($stat_str);
			$map->addView('default',$status,(string)$default_view);
		}
		//设置其他值
		WooBaseApplicationRegistry::setControllerMap($map);

	}


	private function ensure($expr,$message){
		if(! $expr){
			throw new WooBaseAppException($message);
		}
	}
}